package com.itheima.controller;

import com.itheima.common.constant.MessageConstant;
import com.itheima.common.entity.PageResult;
import com.itheima.common.entity.QueryPageBean;
import com.itheima.common.entity.Result;
import com.itheima.pojo.Order;
import com.itheima.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/order")
@Api(tags = "预约管理接口")
public class OrderController {
    @Autowired
    private OrderService orderService;
    /**
     * 分页查询
     */
    @PostMapping("/findPage")
    @ApiOperation("分页查询")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean){
        log.info("分页查询:{}", queryPageBean);
        PageResult pageResult = orderService.findPage(queryPageBean);
        return pageResult;
    }
    /**
     * 修改状态
     */
    @PostMapping("/update")
    @ApiOperation("修改状态")
    public Result update(@RequestBody Order order){
        log.info("修改状态:{}", order);
        orderService.update(order);
        return new Result(true, "修改预约状态成功",null);
    }
}
